<template>
  <el-table :data="tableData" border style="width: 100%">
    <integralgrade-edit ref="integralgradeEdit"></integralgrade-edit>
    <el-table-column prop="borrowAmount" label="借款额度" width="180">
    </el-table-column>
    <el-table-column prop="integralStart" label="积分区间开始" width="180">
    </el-table-column>
    <el-table-column prop="integralEnd" label="积分区间结束"> </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEditintegralGrade(scope.$index, scope.row)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import axios from "axios";
import { init, remove } from "@/api/integralGrade";
import integralgradeEdit from "@/components/integralGrade/integralGradeEdit";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    init() {
      init()
        .then((response) => {
          this.tableData = response.data.data;
        })
        .catch((error) => {
          console.log(error);
        });
    },
    handleDelete(index, row) {
      this.$confirm("确定删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          remove(row.id)
            .then((response) => {
              this.$message.success(response.data.message);
              this.init()
            })
            .catch((error) => {
              console.log("删除失败！", error);
            });
        })
        .catch(() => {});
    },
    async handleEditintegralGrade(index, row) {
      try {
        this.$refs.integralgradeEdit.$emit("openEditintegralGradeDialog", row);
      } catch (error) {}
    },
  },
  components: { integralgradeEdit },
  created() {
    this.init();
  },
  watch: {
  '$route': function (){
    this.init()
  }
}
};
</script>

<style scoped>
</style>

